//
//  UITableView+MCRegisterCellClass.m
//  GridGovernance
//
//  Created by 吴欧 on 2018/1/19.
//  Copyright © 2018年 Bitvalue. All rights reserved.
//

#import "UITableView+MCRegisterCellClass.h"

@implementation UITableView (MCRegisterCellClass)

- (void)mc_registerCellByFiterModels:(NSArray<GDFiterCellModel *> *)models {
    for (GDFiterCellModel *model in models) {
        
        if (model.cellDisplayType == GDCellDisplayNone) {
            continue;
        }
        
        if (model.registType == GDFiterCellRegisterByClass) {
            [self registerClass:model.cellKlass forCellReuseIdentifier:NSStringFromClass(model.cellKlass)];
        }else if (model.registType == GDFiterCellRegisterByXib) {
            [self registerNib:[UINib nibWithNibName:NSStringFromClass(model.cellKlass) bundle:nil] forCellReuseIdentifier:NSStringFromClass(model.cellKlass)];
        }
    }
}

- (void)mc_registerAllCellByFiterModels:(NSArray<GDFiterCellModel *> *)models {
    for (GDFiterCellModel *model in models) {
        if (model.registType == GDFiterCellRegisterByClass) {
            [self registerClass:model.cellKlass forCellReuseIdentifier:NSStringFromClass(model.cellKlass)];
        }else if (model.registType == GDFiterCellRegisterByXib) {
            [self registerNib:[UINib nibWithNibName:NSStringFromClass(model.cellKlass) bundle:nil] forCellReuseIdentifier:NSStringFromClass(model.cellKlass)];
        }
    }
}

- (void)mc_registerCellClasses:(NSArray<Class> *)classes {
    for (Class classType in classes) {
        [self registerClass:classType forCellReuseIdentifier:NSStringFromClass(classType)];
    }
}

- (UITableViewCell *)mc_dequeueReusableCellWithClassType:(Class)classType {
    return [self dequeueReusableCellWithIdentifier:NSStringFromClass(classType)];
}

@end
